<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of ResponderSolicitud
 *
 * @author MFerreira
 */
class ResponderSolicitud extends Module {

    public function index() {
        if ($this->request->submitted()) {
            $IdSolicitud = $this->request->post("IdSolicitud");
            /* @var $Solicitud Solicitudes */
            $Solicitud = $this->model->solicitude->GetById($IdSolicitud);

            $this->assign("solicitude", $Solicitud);
            $this->display();
        } else {
            $this->index();
        }
    }

    public function CambiarEstado() {
        if ($this->request->submitted()) {
            $Solicitud = new solicitudes();
            $Solicitud->setSolicitante(new Trabajadores());

            $this->model->solicitudes->Update($Solicitud);

            if ($Solicitud->getEstado() == 1) {
                $this->assign("IdSolicitud", $Solicitud);
                $this->display("InscribirPracticante");
            } else {
                $this->display();
            }
        } else {
            $this->index();
        }
    }

    /**
     * @export-metadata Bind:this.Practicante
     */
    public function AsignarPracticante() {
        if ($this->request->submitted()) {
            $this->model->practitioners->Create($this->Practicante);

            $this->display();
        } else {
            $this->index();
        }
    }

    private $Practicante;

    public function getPracticante() {

        if (!$this->Practicante) {
            $this->Practicante = new Practicantes();
            $this->Practicante->setTutor(new Trabajadores());
        }

        return $this->Practicante;
    }

}

?>
